package cn.edu.scnu.service;

import cn.edu.scnu.entity.Showorder;
import cn.edu.scnu.mapper.ShoworderMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoworderService extends ServiceImpl<ShoworderMapper, Showorder> {
    @Resource
    private ShoworderMapper showorderMapper;
    public List<Showorder> showorder(String email, String status) {
        QueryWrapper<Showorder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("email", email);
        if (!StringUtils.isEmpty(status)) {
            queryWrapper.eq("status", status);
        }
        queryWrapper.orderByDesc("id");
        return showorderMapper.selectList(queryWrapper);
    }
    public List<Showorder> orderList(String status) {
        QueryWrapper<Showorder> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(status)) {
            queryWrapper.eq("status", status);
        }
        queryWrapper.orderByDesc("id");
        return showorderMapper.selectList(queryWrapper);
    }
}
